import 'package:flutter/cupertino.dart';

import 'package:get/get.dart';
import 'package:hockey/jzx_tabbar.dart';

import '/support_files/assets.gen.dart';

class JzxAppBarBackButton extends StatelessWidget {
  const JzxAppBarBackButton({
    super.key,
    this.color,
    this.superCtx,
  });

  final Color? color;
  final BuildContext? superCtx;

  @override
  Widget build(BuildContext context) {
    // double size = min(22.w, 30);
    return Align(
      alignment: Alignment.centerLeft,
      child: CupertinoButton(
        padding: const EdgeInsets.only(left: 15),
        child: Assets.images.icNavBack.image(
          width: 24,
          height: 24,
          // color: color ?? context.appColors.text,
        ),
        onPressed: () async {
          if (superCtx != null) {
            Navigator.maybePop(superCtx!);
            return;
          }

          final navigator = Navigator.of(context);
          if (navigator.canPop()) {
            navigator.pop();
          } else {
            Get.offAllNamed(kRouteTabbar);
          }
        },
      ),
    );
  }
}
